# Shared -*- makefile -*- for multiple architectures

# # Detect settings from PYTHON package (if defined)
# sinclude ../../src/Makefile.package.settings
# ifeq ($(python_SYSINC),)
# COLVARS_PYTHON_INCFLAGS =
# else
# COLVARS_PYTHON_INCFLAGS = -DCOLVARS_PYTHON $(python_SYSINC)
# endif

# Detect debug settings
ifeq ($(COLVARS_DEBUG),)
COLVARS_DEBUG_INCFLAGS =
else
COLVARS_DEBUG_INCFLAGS = -DCOLVARS_DEBUG
endif

COLVARS_INCFLAGS = -DCOLVARS_LAMMPS $(COLVARS_DEBUG_INCFLAGS) $(COLVARS_PYTHON_INCFLAGS) -I../../src


.SUFFIXES:
.SUFFIXES: .cpp .o


COLVARS_SRCS = \
        colvaratoms.cpp \
        colvarbias_abf.cpp \
        colvarbias_abmd.cpp \
        colvarbias_alb.cpp \
        colvarbias.cpp \
        colvarbias_histogram.cpp \
        colvarbias_histogram_reweight_amd.cpp \
        colvarbias_meta.cpp \
        colvarbias_restraint.cpp \
        colvarcomp_alchlambda.cpp \
        colvarcomp_angles.cpp \
        colvarcomp_apath.cpp \
        colvarcomp_coordnums.cpp \
        colvarcomp.cpp \
        colvarcomp_distances.cpp \
        colvarcomp_gpath.cpp \
        colvarcomp_neuralnetwork.cpp \
        colvarcomp_combination.cpp \
        colvarcomp_protein.cpp \
        colvarcomp_rotations.cpp \
        colvarcomp_volmaps.cpp \
        colvar.cpp \
        colvardeps.cpp \
        colvargrid.cpp \
        colvarmodule.cpp \
        colvarparams.cpp \
        colvarparse.cpp \
        colvarproxy.cpp \
        colvarproxy_io.cpp \
        colvarproxy_replicas.cpp \
        colvarproxy_system.cpp \
        colvarproxy_tcl.cpp \
        colvarproxy_volmaps.cpp \
        colvarscript.cpp \
        colvarscript_commands.cpp \
        colvarscript_commands_bias.cpp \
        colvarscript_commands_colvar.cpp \
        colvars_memstream.cpp \
        colvartypes.cpp \
        colvarvalue.cpp \
        colvar_neuralnetworkcompute.cpp

# Allow to selectively turn off Lepton
ifeq ($(COLVARS_LEPTON),no)

LEPTON_INCFLAGS =

else

LEPTON_DIR = ../lepton
include $(LEPTON_DIR)/Settings.mk
LEPTON_INCFLAGS = $(LEPTON_INC) $(LEPTON_DEF)

endif

COLVARS_OBJS = $(COLVARS_SRCS:.cpp=.o)

%.o: %.cpp
	$(CXX) $(CXXFLAGS) $(COLVARS_INCFLAGS) $(LEPTON_INCFLAGS) -c -o $@ $<

$(COLVARS_LIB): Makefile.deps $(COLVARS_OBJS)
	$(AR) $(ARFLAGS) $(COLVARS_LIB) $(COLVARS_OBJS)


Makefile.deps: $(COLVARS_SRCS)
	@echo > $@
	@for src in $^ ; do \
	  obj=`basename $$src .cpp`.o ; \
	  $(CXX) $(CXXFLAGS) -MM $(COLVARS_INCFLAGS)  $(LEPTON_INCFLAGS) \
	    -MT '$$(COLVARS_OBJ_DIR)'$$obj $$src >> $@ ; \
	  done

include Makefile.deps

